package qq2564874169.tuaotuao.fx.orm;


import qq2564874169.tuaotuao.fx.Dynamic;
import qq2564874169.tuaotuao.fx.FxAutoCloseable;

import java.util.List;

public interface MultipleReader extends FxAutoCloseable {
    <T> List<T> read(Class<T> clazz);

    default <T> T readOne(Class<T> clazz) {
        List<T> items = read(clazz);
        if (items != null && !items.isEmpty()) {
            return items.get(0);
        }
        return null;
    }

    default Dynamic readOne() {
        return readOne(Dynamic.class);
    }

    default List<Dynamic> read() {
        return read(Dynamic.class);
    }
}
